package com.sendcloud.sdk.model;


import com.echat.commonlib.util.StringUtil;

import java.io.File;
import java.util.UUID;

/**
 * Created by huangzhilin on 2018/5/11.
 */
public class EchatMailAttachment {
    private Object attachment;
    private String fileName;

    public EchatMailAttachment() {
    }

    public EchatMailAttachment(Object attachment) {
        this.attachment = attachment;
    }

    public EchatMailAttachment(Object attachment, String fileName) {
        this.attachment = attachment;
        this.fileName = fileName;
    }

    public Object getAttachment() {
        return attachment;
    }

    public void setAttachment(Object attachment) {
        this.attachment = attachment;
    }

    public String getFileName() {
        if (StringUtil.isNotEmpty(fileName)) {
            return fileName;
        } else {
            if (attachment != null) {
                if (attachment instanceof File) {
                    return ((File) attachment).getName();
                } else {
                    return UUID.randomUUID().toString();
                }
            }
        }
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
}
